package cn.thoughtworks.school.notifications.impl;

import cn.thoughtworks.school.notifications.NotificationFactory;
import cn.thoughtworks.school.notifications.Properties;
import cn.thoughtworks.school.services.ProgramCenterService;
import cn.thoughtworks.school.services.UserCenterService;

import java.util.Map;
import java.util.Objects;

public class TutorFollowStudentNotification extends NotificationFactory {

    public TutorFollowStudentNotification(Map data, Properties properties, UserCenterService userCenterService, ProgramCenterService programCenterService) {
        super(data, properties, userCenterService, programCenterService);
    }

    @Override
    protected String getMessage() {
        StringBuilder message = new StringBuilder();
        Map sender = getUser(Long.parseLong(data.get("senderId").toString()));
        Map program = getProgram();

        message.append(program.get("title"))
                .append(" 训练营的助教 ")
                .append(getUserName(sender))
                .append("关注了你!  ")
                .append(getContractInfo(sender));

        return message.toString();
    }

  @Override
  protected String getMessage_en() {
    StringBuilder message = new StringBuilder();
    Map sender = getUser(Long.parseLong(data.get("senderId").toString()));
    Map program = getProgram();

    message
      .append(" Tutor ")
      .append(getUserName(sender)).append("'s ")
      .append(program.get("title"))
      .append(" follow you.  ")
      .append(" His email is ").append(sender.get("email"));

    return message.toString();
  }

    private String getContractInfo(Map sender) {
        Object wechat = sender.get("wechat");
        Object qq = sender.get("qq");
        String result = " Ta 的Email是："+sender.get("email");
        if (!Objects.equals("", wechat) && Objects.nonNull(wechat)) {
            result += " 微信号是：" + wechat;
        }
        if (!Objects.equals("", qq) && Objects.nonNull(qq)) {
            result += " QQ号是：" + qq;
        }
        return result;
    }


}
